package com.example.service.webhook.business.fund.repository;

import javax.annotation.Resource;

import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.example.service.webhook.business.fund.entity.BillRecordEntity;
import com.example.service.webhook.repository.base.BaseDAO;
import com.example.service.webhook.util.DateUtil;
/**
 * 公积金缴存信息
 * ClassName: EducationRepository    
 * date: 2016年7月26日 下午5:35:38   
 * @author yuandong  
 * @version   
 * @since JDK 1.6
 */
@Repository
public class BillRecordRepository extends BaseDAO<BillRecordEntity>{
	
	@Resource(name="templateFund")
    private JdbcTemplate jdbcTemplate;

    public JdbcTemplate getJdbcTemplate() {
		return jdbcTemplate;
	}
    
    public void saveBillRecordEntity(BillRecordEntity entity) throws Exception  {
    	entity.setCreateTime(DateUtil.getCurrentDate());
    	entity.setLastModifyTime(DateUtil.getCurrentDate());
		this.add(entity);
    }
    
    public void updateBillRecordEntity(BillRecordEntity entity) throws Exception  {
    	entity.setLastModifyTime(DateUtil.getCurrentDate());
		this.modify(entity);
    }
    
    public BillRecordEntity getBillRecord(String userId,String customerNumber,String dealTime) throws Exception {
        String tableName = "t_fund_billrecord";
        String sql = "select * from " + tableName + " where userId=? and customerNumber=? and dealTime=?";
        BillRecordEntity pojo = null;
        try{
         pojo = (BillRecordEntity) queryOne(sql, new Object[] { userId,customerNumber,dealTime }, new BillRecordEntity());	
        }catch(EmptyResultDataAccessException e){
        	return null;
        }
        
        return pojo;
    }
    
    
}
